/**
 * @(#)DaoStub.java, 2008-4-30.
 * Copyright 2008  Program Analysis Research Group(PARG),Institute of Software, Peking University.
 * All rights reserved.
 */
package edu.pku.sei.pgie.persistence.dao;

import java.sql.Connection;
import java.util.Calendar;

import javax.sql.DataSource;

/**
 * @author HeLi
 */
public class DAOStub {
    DataSource dataSource;

    public DAOStub() {
        dataSource = DataSourceFactory.getDataSource();
    }

    public synchronized static Long generateUID() {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        return new Long(currentTime);
    }

    public boolean enabled() {
        Connection testConnection = null;
        try {
            testConnection = dataSource.getConnection();
            return true;
        } catch (Exception e) {
            return false;
        } finally {
            try {
                testConnection.close();
            } catch (Exception e) {}
        }
    }
}
